package com.hex.ds.hdrs.app.controller;

import com.hex.ds.hdrs.app.po.AppConf;
import com.hex.ds.hdrs.app.service.impl.AppMainService;
import com.hex.ds.hdrs.log.po.RunningStateLog;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author lwz
 * @date 2020-12-28
 * @des
 */
@Slf4j
@RestController
@RequestMapping("/api/appMain")
public class AppMainController {

    @Autowired
    private AppMainService service;

    @PostMapping("/findRunningInfByCurrentUser")
    @ApiOperation("获取当前用户所属周期作业执行情况")
    public ResponseEntity<Object> findCycleJobRunningInfByCurrentUser(@RequestParam String bizDate) {
        log.info("进入了AppMainController的findRunningInfByCurrentUser方法");
        List list = this.service.findRunningInfByCurrentUser(bizDate);
        return new ResponseEntity<>(list, HttpStatus.OK);
    }

    /**
     * @Method: findAppByCurrentUser
     * @Param: [appConf]
     * @Return: org.springframework.http.ResponseEntity<java.lang.Object>
     * @Description: 获取当前用户所属的应用
     * @Author: ji.tang
     * @Date: 2022/11/11 13:41
     * @Version: V1.0
     */
    @ApiOperation("获取当前用户所属的应用")
    @GetMapping("/findAppByCurrentUser")
    public ResponseEntity<Object> findAppByCurrentUser(AppConf appConf) {
        log.info("【AppMainController的findAppByCurrentUser】");
        List<AppConf> list = this.service.findAppByCurrentUserByAppStatus(appConf);
        return new ResponseEntity(list, HttpStatus.OK);
    }

    @PostMapping("/findRunningLogByCurrentUser")
    @ApiOperation("查询运行日志数据")
    public ResponseEntity<Object> findRunningLogByCurrentUser(@RequestParam Integer pageIndex) {
        log.info("进入了AppMainController的findRunningLogByCurrentUser方法");
        List<RunningStateLog> list = this.service.findRunningLogByCurrentUser(pageIndex);
        return new ResponseEntity<>(list, HttpStatus.OK);
    }

    @GetMapping("/findTaskRunningLog")
    @ApiOperation("查询任务运行日志数据")
    public ResponseEntity<Object> findTaskRunningLog() {
        log.info("进入了AppMainController的findTaskRunningLog方法");
        Map result = this.service.findTaskRunningLog();
        return new ResponseEntity<>(result, HttpStatus.OK);
    }
}
